package com.scott.ch060;

import com.scott.ch060.prize.Prize;
import com.scott.ch060.prize.impl.Book;
import com.scott.ch060.prize.impl.Pad;
import com.scott.ch060.prize.impl.Phone;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 黄后林
 * @version 1.0
 * @note
 * @date 2021-12-18 16:25:14
 */
public class Client {

    public static void main(String[] args) {

        // 抽奖品
        // PrizeUtil<Prize>
        ch1();

        // 抽奖金
        // PrizeUtil<Integer>
        ch2();

    }

    private static void ch2(){
        // 拿到抽奖工具
        PrizeUtil<Integer> prizeUtil = new PrizeUtil<>();


        // 把奖品添加到抽奖工具中
        prizeUtil.addPrize(100);
        prizeUtil.addPrize(200);
        prizeUtil.addPrize(500);
        prizeUtil.addPrize(800);

        // 来 模拟1次抽奖
        Integer prize = prizeUtil.getPrize();
        System.out.println("恭喜你、抽中奖金 "+prize+" 元");

    }


    private static  void ch1(){
        // 拿到抽奖工具
        PrizeUtil<Prize> prizeUtil = new PrizeUtil<>();

        // 初始化奖品
        List<Prize> prizeList =  initPrize();

        // 把奖品添加到抽奖工具中
        for (Prize prize : prizeList) {
            prizeUtil.addPrize(prize);
        }

        // 来 模拟1次抽奖
        Prize prize = prizeUtil.getPrize();
        System.out.println("恭喜你、抽中奖品 "+prize.getPrizeName());

    }

    private static List<Prize> initPrize(){
        Prize phone = new Phone();
        Prize pad   = new Pad();
        Prize book = new  Book();
        List<Prize> list = new ArrayList<>();
        list.add(phone);
        list.add(pad);
        list.add(book);
        return list;

    }
}
